import requests
import urllib


def verify(url):
    relsult = {
        'name': 'Nginx 解析漏洞',
        'vulnerable': False
    }
    headers = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:92.0) Gecko/20100101 Firefox/92.0',
    }
    try:
        rep = requests.get(url, headers=headers)
        vurl1 = url + '/.php'
        vurl2 = url + '/.xxx'
        vurl3 = url + '/.a'
        rep1 = requests.get(vurl1, headers=headers)
        rep2 = requests.get(vurl2, headers=headers)
        rep3 = requests.get(vurl3, headers=headers)
        if 'nginx' in str(rep.headers):
            if len(rep1.text) != len(rep2.text) and len(rep1.text) != len(rep3.text) and len(rep2.text) == len(rep3.text):
                relsult['vulnerable'] = True
                relsult['url'] = url
                relsult['payload'] = vurl1
                relsult['about'] = 'https://vulhub.org/#/environments/nginx/nginx_parsing_vulnerability/'
        return relsult
    except:
        return relsult